<?php
	include_once 'BaseView.php';

	class HeaderView extends BaseView {
		
		public function __construct() {
			$this->showHeader = $this->showUserToolbar = false;
		}
		
		public function render() {
			//if(!isset($this->data)) {
			if($this->data->pageOwner == null) { 
				//default header:
				echo '<div id="header" class="default"><div id="header-inside" class="default"><h2><a href="'.URI::getUrl().'">'.URI::getPageTitle().'</a></h2></div></div>';
			} else {
				//user header
				echo '<div id="header" class="user"><div id="header-inside" class="user">';
				if(isset($this->data->userPage)) {
					if($this->data->userPage->getCustomHeader() != null) {
						echo '<div id="custom-header">'.$this->data->userPage->getCustomHeader().'</div>';
					}
				}
				if($this->data->userPage->getAbout() != null) {
					echo '<div id="about-me"><p><a href="'.URI::getUrl("AboutMe", $this->data->pageOwner).'">O mnie...</a></p></div>';
				}
				echo '<div id="header-main">';
				echo '<div id="avatar"><img src="'.$this->data->user->getAvatar().'" alt="avatar" /></div>';
				echo '<div id="title-wrapper">';
				if($this->data->userPage->getPageTitle()!=null)
					echo '<h2 class="title"><a href="'.URI::getUrl(null, $this->data->pageOwner).'">'.$this->data->userPage->getPageTitle().'</a></h2>';
				else
					echo '<h2 class="title"><a href="'.URI::getUrl(null, $this->data->pageOwner).'">'.$this->data->pageOwner.'</a></h2>';
				if(isset($this->data->userPage)) {
					if($this->data->userPage->getPageSubtitle() != null) {
						echo '<h3 class="subtitle">'.$this->data->userPage->getPageSubtitle().'</h3>';
					}
					echo '</div>';
				} else echo '</div>';
				echo '</div></div></div>';
			}
		}
	}
?>